package com.baizhi.service.impl;

import com.baizhi.dao.BannerDAO;
import com.baizhi.entity.Banner;
import com.baizhi.service.BannerService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class BannerServiceImpl implements BannerService {
    @Autowired
    private BannerDAO bannerDAO;
    @Override
    public PageInfo<Banner> selectAll(Integer page, Integer limit) {
        PageHelper.startPage(page,limit);
        List<Banner> list = bannerDAO.selectAll();
        PageInfo<Banner> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public void deleteByPrimaryKey(Integer bannerId) {

        bannerDAO.deleteByPrimaryKey(bannerId);
    }

    @Override
    public void insert(Banner record) {
        bannerDAO.insert(record);
    }

    @Override
    public Banner selectByPrimaryKey(Integer bannerId) {
        Banner banner = bannerDAO.selectByPrimaryKey(bannerId);
        return banner;
    }

    @Override
    public void updateByPrimaryKeySelective(Banner record) {
        bannerDAO.updateByPrimaryKeySelective(record);
    }
}
